package com.light.mytext.mycustomview

import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import com.example.library.banner.RecyclerViewBannerBase
import com.light.mytext.R
import com.light.mytext.mycustomview.list.ListActivity
import kotlinx.android.synthetic.main.activity_custom_views.*
import java.util.*

/**
 * 自定义View
 * 1、自定义View设置在ScrollView中不显示
 *   ：ScrollView设置android:fillViewport="true"
 * */
class CustomViewsActivity : AppCompatActivity(), View.OnClickListener {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_custom_views)
        initSlider()
        init_Listener()
        Log.i("生命周期==","CustomViewsActivity-onCreate")
    }

    fun initSlider() {
        //轮播图
        val list: MutableList<String> =
            ArrayList()
        list.add("http://img0.imgtn.bdimg.com/it/u=1352823040,1166166164&fm=27&gp=0.jpg")
        list.add("http://img0.imgtn.bdimg.com/it/u=1352823040,1166166164&fm=27&gp=0.jpg")
        list.add("http://img0.imgtn.bdimg.com/it/u=1352823040,1166166164&fm=27&gp=0.jpg")
        banner.initBannerImageView(list,
            RecyclerViewBannerBase.OnBannerItemClickListener { position ->
                Toast.makeText(
                    this@CustomViewsActivity,
                    "clicked:$position",
                    Toast.LENGTH_SHORT
                ).show()
            })
        banner.setShowIndicator(true)


    }

    private fun init_Listener() {
        tv_customgb.setOnClickListener {
            startActivity(Intent(this,LinePointActivity::class.java))
        }
        //360度滑动摇杆
        tv_remote.setOnClickListener {
            startActivity(Intent(this,MyRemoteControlActivity::class.java))
        }
        //重叠View
        tv_line.setOnClickListener {
            startActivity(Intent(this,MyPinJieActivity::class.java))
        }
        //可拖动列表
        tv_drag.setOnClickListener {
            startActivity(Intent(this, ListActivity::class.java))
        }
        //可拖动列表
        tv_table.setOnClickListener {
            startActivity(Intent(this, TableActivity::class.java))
        }
        //仿切模机图片操作
        tv_pic.setOnClickListener {
            startActivity(Intent(this, PicActivity::class.java))
        }
    }

    override fun onClick(v: View?) {
        when (v?.id) {
        }
    }
    override fun onStart() {
        super.onStart()
        Log.i("生命周期==","CustomViewsActivity-onStart")
    }

    override fun onResume() {
        super.onResume()
        Log.i("生命周期==","CustomViewsActivity-onResume")
    }

    override fun onRestart() {
        super.onRestart()
        Log.i("生命周期==","CustomViewsActivity-onRestart")
    }

    override fun onPause() {
        super.onPause()
        Log.i("生命周期==","CustomViewsActivity-onResume")
    }

    override fun onStop() {
        super.onStop()
        Log.i("生命周期==","CustomViewsActivity-onResume")
    }

    override fun onDestroy() {
        super.onDestroy()
        Log.i("生命周期==","CustomViewsActivity-onDestroy")
    }

}
